#include <stdio.h>
#include <stdlib.h>

#include <time.h>
int main() {
	int score = 0;
	int num1, num2, op, answer, correct;
	srand(time(0));
	
	printf("欢迎来到加减法练习！共10题，每题10分。\n");
	
	for (int i = 0; i < 10; i++) {
		op = rand() % 2;
		
		if (op == 0) { 
			num1 = rand() % 51;   
			num2 = rand() % (51 - num1); 
			correct = num1 + num2;
			printf("第%d题: %d + %d = ", i+1, num1, num2);
		} else {
			num1 = rand() % 51 + 50;
			num2 = rand() % (num1 + 1);
			correct = num1 - num2;
			printf("第%d题: %d - %d = ", i+1, num1, num2);
		}
		
		scanf("%d", &answer);
		
		if (answer == correct) {
			
			score += 10;
			printf("正确！\n");
		} else {
			printf("错误，正确答案是：%d\n", correct);
		}
	}
	
	printf("答题结束，你的最终得分是：%d分\n", score);
	return 0;
}
